import React, { Component, Fragment } from 'react'
import Loading from './pages/Loading.js'
import { connect } from 'react-redux'
class App extends Component {
  constructor(props) {
    super(props)
    this.state = {
      message: '加载',
    }
  }
  render() {
    const { loadingFlag } = this.props
    return (
      <Fragment>
        {loadingFlag ? <Loading></Loading> : null}

        {this.props.children}
      </Fragment>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    loadingFlag: state.loadingFlag,
  }
}
const mapDispatchToProps = (dispatch) => {
  return {}
}
//最后利用store挂钩

export default connect(
  mapStateToProps, //这里面放的是数据
  mapDispatchToProps //里面放的是操作的数据的方法
)(App)
